package com.atguigu.jdbc2;

import com.atguigu.jdbc.JDBCUtils2;
import com.atguigu.jdbc.Student;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.junit.Test;

import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.util.List;

public class DBUtils2 {
    @Test
    public void test() throws SQLException {
        QueryRunner queryRunner = new QueryRunner();
        String sql = "insert into demo1(id,username) values(?,?)";
        queryRunner.update(JDBCUtils2.getConnect(),sql,15,"wzx");
    }
    @Test
    public void test1() throws SQLException {
        QueryRunner queryRunner = new QueryRunner();
        String sql = "select * from demo1 where id = ?";
        Student query = queryRunner.query(JDBCUtils2.getConnect(), sql, new BeanHandler<Student>(Student.class),15);
        System.out.println(query);
    }
}
